<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var obj = {
            "uname": "张三",
            "age": 21
        }
        console.log(obj);

        // 初始化的时候，里面有值
        // let dic = new Map({ubane:"张三"})
        // let div = new([{uname:"张三"}])

        let dic = new Map([
            ["uname", "张三"],
            ["age", 21]
        ])
        console.log(dic);

        // 创建空Map
        let dic = new Map()

        // map的key可以是任何数据类型
        dic.set("uname", "张三")
        dic.set("age", 21)
        dic.set({}, "个人信心")
        dic.set(function () {}, "我会说话")
        dic.set(true, "是否考试通过")
        console.log(dic);

        // 添加
        dic.set("uname", "张三")
        dic.set("address", "北京")

        // 获取
        console.log(dic.get("uname"));
        console.log(dic);

        // 删除
        dic.delete("uname")
        console.log(dic);

        // 清空
        dic.clear()
        console.log(dic);

        // 遍历
        dic.forEach((item.index) => {
            console.log(item, index);
        })

        console.log(dic);
        for (v of dic) {
            console.log(v);
        }
    </script>
</body>

</html>